#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include "go.h" 
#include "go.h"
#include "CanP_HostCom.h"
#include "canp_hostcom.h"
#include "roadway_check.h"
#include "delay.h"
#include "roadway_check.h"
#include "data_base.h"
#include "Rc522.h"
#include "infrared.h"
#include "syn7318.h"
#include "ultrasonic.h"
#include "tba.h"
#include "math.h"
#include "can_user.h"
#include "bh1750.h"
#include "arithmetic.h"
#define MAX 20

//255以内的质数
#define static int Prime_Number[]={0x02,0x03,0x05,0x07,0x0B,0x0D,0x11,0x13,0x17,0x1D,0x1F,0x25,0x29,0x2B,0x2F,0x35,0x3B,0x3D,0x43,0x47,0x49,0x4F,0x53,0x59,0x61,0x65,0x67,0x6B,0x6D,0x71,0x7F,0x89,0x8B,0x95,0x97,0x9D,0xA3,0xA7,0xAD,0xB3,0xB5,0xBF,0xC1,0xC1,0xC5,0xC7,0xD3,0xDF,0xE3,0xE5,0xE9,0xEF,0xF1,0xFB};

static 	uint8_t M01[6];//二维码获取的数据

uint8_t str[50];	
uint8_t k12[6];//开启烽火台	

/********************************************
	函数名称：Fast_power_model_algorithm
	参数：a，p，m
	返回值：
	作用：快速功率模型算法//多幂运算
*********************************************/	
uint8_t pow_Mod(int MIN,uint8_t MAX_D,uint8_t MAX_N)
{
	uint16_t num=1;
	for(uint8_t i=0;i<MAX_D;i++)
	{
		num *= MIN;
		if (num > MAX_N)
		{
			num %= MAX_N;
		}
	}
	
	return (uint8_t)num;
}
	
	
/********************************
FFT变换
函数名称：Reverse8
输入参数：x
返回参数：空
将传入的数据进行二进制前后倒置
*********************************/
void Reverse8(uint8_t *x)
{

	*x = ((*x & 0x0F) << 4) + ((*x & 0xF0) >> 4);

	*x = ((*x & 0x33) << 2 )+ ((*x & 0xCC) >> 2);

	*x = ((*x & 0x55) << 1 )+ ((*x & 0xAA) >> 1);

}
/********************************
FFT变换
函数名称：Reverse16
输入参数：x
返回参数：空
将传入的数据进行二进制前后倒置
*********************************/
void Reverse16(uint16_t *x)

{

	*x = ((*x & 0xFF) << 8) + ((*x & 0xFF00) >> 8);

	*x = ((*x & 0x0F0F) << 4 )+ ((*x & 0xF0F0) >> 4);

	*x = ((*x & 0x3333) << 2 )+ ((*x & 0xCCCC) >> 2);
	
	*x = ((*x & 0x5555) << 1 )+ ((*x & 0xAAAA) >> 1);
}

//判断是否互质
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else 
        return gcd(b,a%b);
}


/*************************
江苏的棋盘算法
函数名称：JS_chessboard
输入参数：str	//从二维码中获取得数据
返回值：空

**************************/
void JS_chessboard(char *str)
{
	int count = 0;
	char *p = str;
	int PAi = 0;

	uint8_t PA[MAX];
	uint16_t M01[6];//二维码获取的数据
	uint8_t M01_1[2];

	while (*p != '\0')
	{
		if ((*p >= 'A'&&*p <= 'Z') || (*p >= 'a'&&*p <= 'z'))
		{
			PA[PAi++] = *p;
			PA[PAi] = '\0';
			count++;
		}
		if (count == 6)
		{
			break;
			PA[PAi] = '\0';
		}
		p++;
	}
	PAi = 0;
	count = 0;
	while (PA[PAi] != '\0')
	{
		if (isupper(PA[PAi]))
		{
			if (PA[PAi] == 'X' || PA[PAi] == 'S' || PA[PAi] == 'N' || PA[PAi] == 'I' || PA[PAi] == 'D')
			{
				M01_1[0] = 0x05;

			}
			else if (PA[PAi] == 'E' || PA[PAi] == 'G' || PA[PAi] == 'A' || PA[PAi] == 'T' || PA[PAi] == 'J')
			{
				M01_1[0] = 0x06;
			}
			else if (PA[PAi] == 'K' || PA[PAi] == 'F' || PA[PAi] == 'Z' || PA[PAi] == 'U' || PA[PAi] == 'P')
			{
				M01_1[0] = 0x07;
			}
			else if (PA[PAi] == 'Q' || PA[PAi] == 'L' || PA[PAi] == 'Y' || PA[PAi] == 'B' || PA[PAi] == 'V')
			{
				M01_1[0] = 0x08;
			}
			else if (PA[PAi] == 'W' || PA[PAi] == 'R' || PA[PAi] == 'M' || PA[PAi] == 'H' || PA[PAi] == 'C' || PA[PAi] == 'O')
			{
				M01_1[0] = 0x09;
			}
			if (PA[PAi] == 'E' || PA[PAi] == 'K' || PA[PAi] == 'Q' || PA[PAi] == 'W')
			{
				M01_1[1] = 0x0A;
			}
			else if (PA[PAi] == 'X' || PA[PAi] == 'G' || PA[PAi] == 'F' || PA[PAi] == 'L' || PA[PAi] == 'R')
			{
				M01_1[1] = 0x0B;
			}
			else if (PA[PAi] == 'S' || PA[PAi] == 'A' || PA[PAi] == 'Y' || PA[PAi] == 'M')
			{
				M01_1[1] = 0x0C;
			}
			else if (PA[PAi] == 'N' || PA[PAi] == 'T' || PA[PAi] == 'Z' || PA[PAi] == 'B' || PA[PAi] == 'H')
			{
				M01_1[1] = 0x0D;
			}
			else if (PA[PAi] == 'I' || PA[PAi] == 'U' || PA[PAi] == 'C')
			{
				M01_1[1] = 0x0E;
			}
			else if (PA[PAi] == 'D' || PA[PAi] == 'J' || PA[PAi] == 'P' || PA[PAi] == 'V' || PA[PAi] == 'O')
			{
				M01_1[1] = 0x0F;
			}

		}
		else
		{
			if (PA[PAi] == 'q' || PA[PAi] == 't' || PA[PAi] == 'r' || PA[PAi] == 'o' || PA[PAi] == 'f')
			{
				M01_1[0] = 0x00;

			}
			else if (PA[PAi] == 's' || PA[PAi] == 'p' || PA[PAi] == 'j' || PA[PAi] == 'e' || PA[PAi] == 'x')
			{
				M01_1[0] = 0x01;
			}
			else if (PA[PAi] == 'a' || PA[PAi] == 'm' || PA[PAi] == 'i' || PA[PAi] == 'd' || PA[PAi] == 'w')
			{
				M01_1[0] = 0x02;
			}
			else if (PA[PAi] == 'u' || PA[PAi] == 'h' || PA[PAi] == 'l' || PA[PAi] == 'v' || PA[PAi] == 'z' || PA[PAi] == 'c')
			{
				M01_1[0] = 0x03;
			}
			else if (PA[PAi] == 'g' || PA[PAi] == 'b' || PA[PAi] == 'y' || PA[PAi] == 'k' || PA[PAi] == 'n')
			{
				M01_1[0] = 0x04;
			}
			if (PA[PAi] == 'q' || PA[PAi] == 's' || PA[PAi] == 'a' || PA[PAi] == 'u' || PA[PAi] == 'g')
			{
				M01_1[1] = 0x0A;
			}
			else if (PA[PAi] == 't' || PA[PAi] == 'm' || PA[PAi] == 'h' || PA[PAi] == 'b')
			{
				M01_1[1] = 0x0B;
			}
			else if (PA[PAi] == 'r' || PA[PAi] == 'p' || PA[PAi] == 'i' || PA[PAi] == 'l')
			{
				M01_1[1] = 0x0C;
			}
			else if (PA[PAi] == 'o' || PA[PAi] == 'j' || PA[PAi] == 'd' || PA[PAi] == 'v' || PA[PAi] == 'y')
			{
				M01_1[1] = 0x0D;
			}
			else if (PA[PAi] == 'e' || PA[PAi] == 'w' || PA[PAi] == 'z' || PA[PAi] == 'k')
			{
				M01_1[1] = 0x0E;
			}
			else if (PA[PAi] == 'f' || PA[PAi] == 'x' || PA[PAi] == 'c' || PA[PAi] == 'n')
			{
				M01_1[1] = 0x0F;
			}

		}
		PAi++;
		M01[count++] = M01_1[0] * pow(2, 4) + M01_1[1];
	}
	k12[0] = (M01[0] + M01[1]) % 0xff;
	k12[1] = abs(M01[0] - M01[1]) % 0xff;
	k12[2] = (M01[2] + M01[3]) % 0xff;
	k12[3] = abs(M01[2] - M01[3]) % 0xff;
	k12[4] = (M01[4] + M01[5]) % 0xff;
	k12[5] = abs(M01[4] - M01[5]) % 0xff;

}

/*************************
2016年国赛
函数名称：GS_Hamming
输入参数：str
返回值：空
补位
汉明算法
**************************/
void GS_Hamming(char *str)
{
	int i=0,n=0;
	uint8_t  M001[42];
	uint8_t M02[48];
	uint8_t Zg=0;
	uint8_t M03[6];
	
	while(str[i]!='\0')
	{
		uint8_t M001_1[7];
		for(int j=0;j<7;j++)
		{
			M001_1[6-j]=str[i]%2;
			str[i]/=2;
		}
		for(int j=0;j<7;j++,n++)
		{
			M001[n]=M001_1[j];
		}
		i++;
	}
	
	for(int j=0,count=0;j<42;count++)
	{
		if(count==0||count==1||count==3||count==7||count==15||count==31)
		{
			M02[count]=3;
		}
		else
		{
			M02[count]=M001[j++];
		}
	}
	for(int j=0;j<48;j++)
	{
		if(M02[j]==1)
		{
			Zg^=(j+1);
		}
	}
	
	uint8_t M02_1[6];
	for(int j=0;j<6;j++)
	{
		M02_1[j]=Zg%2;
		Zg/=2;
	}
	for(int j=0,n=0;j<48;j++)
	{
		if(M02[j]==3)
		{
			M02[j]=M02_1[n++];
		}
	}
	for(int i=0,n=0;i<48;n++)
	{
		M03[n]=0;
		for(int j=0;j<8;j++,i++)
		{
			M03[n]+=M02[i]*pow(2,7-j);
		}
	}
	Send_ZigbeeData_To_Fifo(M03,6);
} 



/******************************************
2017年国赛算法
函数名称:GS_RSA
参数:str
返回值:
RSA算法
*******************************************/
void GS_RSA(uint8_t *str)
{	
	uint8_t MIN[6]={1,2,3,4,5,6};
	char as[5];
	int decimalism[10];
	uint8_t number[20];
	uint8_t MAX_P=0,MAX_Q=0,MAX_N=0,MAX_S=0,MAX_E=0,MAX_D=0;
	int i=0,n=0,j=0;
	int count=0,con=0;
	while(str[i]!='\0')
	{
		if(str[i]==',')
		{
			decimalism[count++]=(int)atoi(as);
			decimalism[count]='\0';
			con=0;
			as[con]='\0';
		}
		else
		{
			as[con++]=str[i];
			as[con]='\0';
		}
		i++;

	}
	decimalism[count++]=(int)atoi(as);
	decimalism[count]='\0';
	
	i=0;
	n=0;
	while(decimalism[i]!='\0')
	{
		n=0;
		while(Prime_Number[n]!='\0')
		{
			
			if(decimalism[i]<Prime_Number[n])
			{
				break;
			}
			else if(Prime_Number[n]==decimalism[i])
			{
				number[j++]=decimalism[i];
				number[j]='\0';
				
			}
			n++;
		}
		i++;
	}
	j=0;
	while(number[j++]!='\0');
	MAX_P=number[j-2];
	MAX_Q=number[j-3];
	MAX_N=MAX_P*MAX_Q;
	MAX_S=(MAX_P-1)*(MAX_Q-1);
	for(int i=2;i<sqrt(MAX_S);i++)
	{
		if(gcd(i,MAX_S)==1)
		{
			MAX_E=i;
			break;
		}
	}
	for(int i=1;i<256;i++)
	{
		if((MAX_E*i-1)%MAX_S==0)
		{
			MAX_D=i;
			break;
		}
	}
	for(int i=0;i<6;i++)
	{
		k12[i]=pow_Mod(MIN[i], MAX_D, MAX_N);
	}
	
	Send_ZigbeeData_To_Fifo(k12,6);
}


/******************************************
2018年国赛算法
函数名称:CRC_RSA
参数:str
返回值:
CRC算法
*******************************************/
void CRC_RSA(char *str)
{
	uint8_t  letter[4];
	uint16_t CRC_register=0xFFFF;
	int count=0,num=0;
	int  polynomial[10],quantic=0;

	while(str[count]!='\0')
	{
		if((isalpha(str[count]))&&num<2&&str[count]!='x'&&str[count]!='X')
		{
			letter[num++]=str[count];
			letter[num]='\0';
		}
		count++;
	}
	num=3;
	while(count--)
	{
		if(isalpha(str[count])&&str[count]!='x'&&str[count]!='X')
		{
			letter[num--]=str[count];
		}
		if(num==1)
		{
			break;
		}
	}
	count=0;
	while(str[count]!='\0')
	{
		char zg[10];
		int zgi=0;
		if(str[count]=='x')
		{
			count++;
			while(isdigit(str[count]))
			{
					zg[zgi++]=str[count++];
					zg[zgi]='\0';
			}

		polynomial[quantic++]=atof(zg);
		polynomial[quantic]='\0';
		}
		else if((0x09>=str[count])&&str[count+1]!='x'&&str[count+2]!='x'&&str[count+3]!='x')
		{
				polynomial[quantic++]='a';
				polynomial[quantic]='\0';
				zg[0]='\0';
		}
		count++;
	}
	uint16_t TGA=0;
	quantic=0;
	int max=0,NUM;
	while(polynomial[quantic]!='\0')
	{
		if(polynomial[quantic]<=16)
		{
			if(max<=polynomial[quantic])
			{
				max=polynomial[quantic];
				NUM=quantic;
			}
		}
		quantic++;

	}
	quantic=0;
	while(polynomial[quantic]!='\0')
	{
		if(polynomial[quantic]<=0x10)
		{
			if(quantic==NUM)
			{
				quantic++;
				continue;
			}
			else if(polynomial[quantic]!='a')
			{
				TGA+=1<<polynomial[quantic];
			}

		}
		else if(polynomial[quantic]=='a')
		{
			TGA+=1;
		}			

		quantic++;
	}
	Reverse16(&TGA);
	for(int i=0;i<4;i++)
	{
		CRC_register^=letter[i];
		for(int j=0;j<8;j++)
		{
			uint16_t zga=CRC_register;
			CRC_register=CRC_register>>1;
			if((zga&0x01)==0x01)
			{
				CRC_register^=TGA;
			}
		}
		
	}
	k12[0]=(CRC_register&0xff00)>>8;
	k12[5]=(CRC_register&0xff);
	for(int i=1;i<5;i++)
	{
		k12[i]=letter[i-1];
	}
	Send_ZigbeeData_To_Fifo(k12,6);
}

/**************************************************
函数名称：HN_2018_1
参数：str
返回值：空
湖南2018年第一题算法
***************************************************/
void HN_2018_1(char *str)
{
	uint32_t AB[2]={0,0},j=0;
	uint8_t FH;
	char zg[10];
	int i=0,n=0;
	int count=0;
	while(str[i]!='\0')
	{
		n=0;

		if(str[i]=='0'&&str[i+1]=='x')
		{
			i+=2;
			while(isdigit(str[i])||(str[i]>='a'&&str[i]<='f')||(str[i]>='A'&&str[i]<='F'))
			{
				zg[n++]=str[i++];
				zg[n]='\0';
			}
			int m=0;
			while(n+1)
			{
				if(isdigit(zg[n]))
				{
					AB[j]+=(zg[n]-'0')*pow(16,m-1);
				}
				else if(zg[n]>='a'&&zg[n]<='f')
				{
					AB[j]+=(zg[n]-'a'+10)*pow(16,m-1);
				}
				else if(zg[n]>='A'&&zg[n]<='F')
				{
					AB[j]+=(zg[n]-'A'+10)*pow(16,m-1);
				}
				m++;
				n--;	
			}
			
			j++;
		}
		else if(str[i]=='+'||str[i]=='-'||str[i]=='*'||str[i]=='%')
		{
			FH=str[i++];
		}
		else if(str[i]==',')
		{
			switch(FH)
			{
				case '+':
					k12[count++]=(AB[0]+AB[1])%0xff;
				break;
				case '-':
					k12[count++]=(AB[0]-AB[1])%0xff;
				break;
				case '*':
					k12[count++]=(AB[0]*AB[1])%0xff;
				break;
				case '%':
					k12[count++]=(AB[0]%AB[1])%0xff;
				break;
			}
			j=0;
			i++;
			AB[0]=0;
			AB[1]=0;
			
		}
		else if(isdigit(str[i]))
		{
			while(isdigit(str[i]))
			{
				zg[n++]=str[i++];
				zg[n]='\0';
			}
			AB[j++]=atof(zg);
		}
	}
	switch(FH)
	{
		case '+':
			k12[count++]=AB[0]+AB[1];
		break;
		case '-':
			k12[count++]=AB[0]-AB[1];
		break;
		case '*':
			k12[count++]=AB[0]*AB[1];
		break;
		case '%':
			k12[count++]=AB[0]%AB[1];
		break;
	}
	for(int i=0;i<6;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(k12[i]<k12[j])
			{
				uint8_t k2=k12[i];
				k12[i]=k12[j];
				k12[j]=k2;
			}
		}
	}
	Send_ZigbeeData_To_Fifo(k12,6);
}

/**************************************************
函数名称：HN_2018_A
参数：str
返回值：空
湖南2018年第一题算法
***************************************************/
void HN_2018_A(char *str)
{
	uint16_t k13[6];
	int count=0;
	int i=0;
	while(count<6)
	{
		if(str[i]=='1')
		{
			i++;
			if(str[i]=='1')
			{
				k13[count++]='B';
			}
			else if(str[i]=='0')
			{
				k13[count++]='H';
			}
		}
		else if(str[i]=='0')
		{
			i++;
			if(str[i]=='0')
			{
				k13[count++]='K';
			}
			else if(str[i]=='1')
			{
				i++;
				if(str[i]=='0')
				{
					k13[count++]='M';
				}
				else if(str[i]=='1')
				{
					k13[count++]='T';	
				}
			}
		}
		i++;
	}
	k12[0]=(k13[0]+k13[1])%0xff;
	uint16_t k14=k13[2]+0xff+1;
	k12[1]=(k14-k13[3])%0xff;
	k12[2]=(k13[4]^k13[5])%0xff;
	k12[3]=k13[0];
	k12[4]=k13[0];
	k12[5]=k13[5];
	for(int i=0;i<6;i++)
	{
		if(k12[3]>k13[i])
		{
			k12[3]=k13[i];
		}
		if(k12[4]<k13[i])
		{
			k12[4]=k13[i];
		}
	}
	for(int i=0;i<6;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(k12[j]<k12[i])
			{
				uint8_t kd=k12[j];
				k12[j]=k12[i];
				k12[i]=kd;
			}
		}
			
	}
	Send_ZigbeeData_To_Fifo(k12,6);
}


/**************************************************
函数名称：HN_2018_B
参数：str
返回值：空
湖南2018年第B题算法

123<-CDBEFA->456
***************************************************/
void HN_2018_B(char *str)
{
	int head=0;
	int i=8;
	uint16_t k13[6];
	while(i)
	{
		if(str[i]=='-'&&str[i-1]=='<')
		{
			head=i;
			break;
		}
		i--;
	}
	int count=0;
	for(int i=head+1;count<6;i++)
	{
		k13[count++]=str[i];
	}
	
	k12[0]=(k13[0]+k13[1])%0xff;
	uint16_t k14=k13[2]+0xff;
	k12[1]=(k14-k13[3]+1)%0xff;
	k12[2]=(k13[4]^k13[5])%0xff;
	k12[3]=k13[0];
	k12[4]=k13[0];
	k12[5]=k13[2];
	
	for(int i=0;i<6;i++)
	{
		if(k12[3]>k13[i])
		{
			k12[3]=k13[i];
		}
		if(k12[4]<k13[i])
		{
			k12[4]=k13[i];
		}
	}
	for(int i=0;i<6;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(k12[j]<k12[i])
			{
				uint8_t kd=k12[j];
				k12[j]=k12[i];
				k12[i]=kd;
			}
		}
			
	}

	Send_ZigbeeData_To_Fifo(k12,6);
}

/************************************************
名称:Simulate_One<维吉尼亚密码加密>
参数：
返回值：

*************************************************/
void Simulate_One(char *str)
{
	//明文
	char *p = str;
	//密钥
	char Secret_Key[] = { "HELLOH" };
	int longP = sizeof(p);
	int longS = sizeof(Secret_Key);
	//密钥增加
	if (longS < longP)
	{
		for (int i = longS + 1; i <= longP; i++)
		{
			Secret_Key[i] = Secret_Key[i%longS];
		}
	}

	int i = 0;
	//转字母
	while (i < 6)
	{
		if (isdigit(p[i]))
		{
			p[i] = p[i] + 0x11;
		}
		i++;
	}

	//明文加密
	for (int i = 0; i < 6; i++)
	{
		char sc = p[i] + (Secret_Key[i] - 'A');
		if (sc > 'Z')
		{
			k12[i] = sc - 26;
		}
		else
		{
			k12[i] = sc;
		}
	}

	


}
/*********************************************
函数名称：CouplingCalculation
参数：str
返回值:空
作用:偶合算法实现
**********************************************/
#if 1

void CouplingCalculation(char *str)
{
	uint8_t CoupledBase[]={0x05,0x07,0x09,0x0B,0x0D,0x0F};
	uint8_t CC_R=1;
	uint8_t CC_T;
	uint8_t num;
	//取出偶数
	//乘积为R
	char *p=str;
	int i=0;
	while(str[i]!='\0')
	{
		if(isdigit(str[i])&&((str[i]-'0')%2==0))
		{
			CC_R=CC_R*(str[i]-'0');
		}
		i++;
	}
	i=0;
	//求R相邻最小的的质数T
	while(Prime_Number[i]<256)
	{
		if(Prime_Number[i]>CC_R)
		{
			CC_T=Prime_Number[i-1];
			break;
		} 
		i++;
	}
	
	for(i=0;i<6;i++)
	{
		k12[i]=CC_T%CoupledBase[i];
	}
	
	Send_ZigbeeData_To_Fifo(k12,6);
	//T对M求取余M{5,7,9,11,13,15};
	
}
#endif

/*********************************************
函数名称：PathAnalysis
参数：str
返回值：空
作用：解析出字符串中的地址，存入通讯协议中
**********************************************/

#if 1
uint8_t PathaDdress[15][8];
void PathAnalysis(char *str)
{
	PathaDdress[14][0]=0x55;
	PathaDdress[14][1]=0x02;
	PathaDdress[14][2]=0xE0;
	PathaDdress[14][3]=0x00;
	PathaDdress[14][4]=0x00;
	PathaDdress[14][5]=0x00;
	PathaDdress[14][6]=0x00;
	PathaDdress[14][7]=0xBB;
	char *p=str;
	uint8_t instruction=0xE1;
	
	int i=0;
	int j=0;
	while(p[i]!='\0')
	{
		if((p[i]>='A'&&p[i]<='G')&&(p[i]>='1'&&p[i+1]<='7'))
		{
			uint8_t coordinate=0;
			int instruct =3;
			while(1)
			{
				if(instruct==3)
				{
					PathaDdress[j][0]=0x55;
					PathaDdress[j][1]=0x02;	
					PathaDdress[j][7]=0xBB;
				}
				if(p[i]>='A'&&p[i]<='G')
					coordinate=(p[i]-'A'+0x0A)<<4;
				else if(p[i]>='a'&&p[i]<='g')
					coordinate=(p[i]-'a'+0x0A)<<4;
				if(p[i]>='1'&&p[i]<='7')
				{
					coordinate+=(p[i]-'0');
					PathaDdress[j][instruct]=0;	
					PathaDdress[j][instruct++]=coordinate;
					PathaDdress[j][instruct]=0;					
				}
				if(instruct==6||p[i]=='\0')
				{
					if(p[i]=='\0')
					{
						while(instruct<6)
						{
							PathaDdress[j][instruct++]=0x00;
						}
					}
					PathaDdress[j][2]=instruction+j;
					j++;
					instruct=3;
					if(p[i]=='\0')
						break;
				}
				i++;
			}
			
		}
		i++;
	}
	
	for(int n=0;n<j;n++)
	{	
		Stop_Flag=0;
		while(Stop_Flag!=0xEE)
		{
			Send_ZigbeeData_To_Fifo(PathaDdress[n],8);
			Master_slave_interaction();

			delay_s(1);
		}
	}
	Send_ZigbeeData_To_Fifo(PathaDdress[14],8);
	Cba_Beep(50,10,10);
}
#endif